package org.example.shop_db.controller;

import org.example.shop_db.pojo.Product;
import org.example.shop_db.pojo.Result;
import org.example.shop_db.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private ProductService productService;
    //添加商品
    @PostMapping
    public Result add(Product product) {
        boolean p = productService.add(product);
        if (p) {
            return Result.success("添加成功");
        }else {
            return Result.error("添加错误,请稍后再试");
        }
    }

}
